Next | Prev | Up | Top | Contents | Index

Put Functions wput() and rput()

Every STREAMS driver and module must define a put() function to handle messages as they are delivered to a queue.

The prototype of a put() function is as follows:

int name(queue_t *q, mblk_t *mp);

Because the put() function for a given queue is addressed from the associated qinit structure, there is no requirement that the put() function be a public name, and no requirement that it begin with the prefix string. The put() function for the write queue, which handles messages moving "downstream" from the user process toward the driver, is conventionally called the wput() function. All write queues need a wput() function.

The put() function for the read queue, which handles messages moving "upstream" from the driver toward the user process, is conventionally called the rput() function. In some cases the rput() function is not required, for example in a driver where all upstream messages are generated by an interrupt handler.

Typically, a put() function decides what to do by switching on the message type value from mp->b_datap->db_type. A put routine must do at least one of the following:

When all processing is deferred to the service function, the address of the kernel function putq() can be given as a queue's put() function.

In a multiprocessor, a put() function can be called concurrently with user-level code, and concurrently with another put() function for the same or a different queue. A service function for the same or different queue can also be executing concurrently.


Next | Prev | Up | Top | Contents | Index